package whlogger.launcher.loginfields.views.controller;

import javax.swing.JPanel;
import whlogger.launcher.interfaces.jpanelcontroller.IJPanelController;
import whlogger.launcher.loginfields.views.LogInJPanel;
import whlogger.launcher.loginfields.views.action.LoginDataValidator;
import whlogger.launcher.loginfields.views.repositories.BehaviorRepository;
import whlogger.launcher.loginfields.views.repositories.ListenerRepository;
import whlogger.launcher.models.userdata.LogInData;

/**
 *
 * @author d3rbastl3r
 */
public class LogInJPanelController implements IJPanelController{
    private LogInJPanel         jPanel              = null;
    private BehaviorRepository  behaviorRepository  = null;
	private ListenerRepository	listenerRepository	= null;
	
    private LogInData           logInData           = null;
    
    public LogInJPanelController(){
        this.jPanel = new LogInJPanel(this);
    }
    
    public BehaviorRepository getBehaviorRepository(){
        return this.behaviorRepository;
    }
    
    public void setBehaviorRepository(BehaviorRepository repository){
        this.behaviorRepository = repository;
    }
	
	public ListenerRepository getListenerRepository(){
        return this.listenerRepository;
    }
    
    public void setListenerRepository(ListenerRepository repository){
        this.listenerRepository = repository;
    }
    
    public LogInData getLogInData(){
        return this.logInData;
    }
    
    public void setLogInData(String nickname, String password){
		LoginDataValidator validator = new LoginDataValidator();
		
		if(validator.isNicknameValide(nickname) != LoginDataValidator.ValidationKey.IS_VALIDE){
			System.out.println("TODO Dialog anzeigen: Nickname is not valide!");
		}
		
		if(validator.isPasswordValide(password) != LoginDataValidator.ValidationKey.IS_VALIDE){
			System.out.println("TODO Dialog anzeigen: Password is not valide!");
		}
		
        this.logInData = new LogInData(nickname, password);
    }
    
    @Override
    public JPanel getJPanel(){
        return this.jPanel;
    }
}
